home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
5
/
CHASSIS_
/
PRINTWIN.C
< prev
next >
Wrap
Text File
|
1992-05-14
|
4KB
|
114 lines
/************************************************************************************/
/* PrintWindowProc */
/************************************************************************************/
#include "MyHeaders.h"
int PrintWindowProc(int Which)
{
int PrintWindRetCode = 0;
TEHandle myPrTEH;
int outHeight, outLines, outVert, outScroll;
long outPageNo;
Rect IRect;
Handle IHandle;
Rect dlogRect;
int rectHeight, rectWidth;
int newH, newV;
switch (windTbl[Which].windRec.refCon) /* Get calling procedure info from */
{ /* the window table */
case (ProcText): /* text window procedure */
GetPort(&workGrafPtr); /* save GrafPort ptr */
CursorSelect(NIL, NIL, watchCursor); /* set the cursor */
/* get "Printing" dialog */
myDlogPtr = GetNewDialog (141, NIL, (WindowPtr) -1);
dlogRect = (*myDlogPtr).portRect; /* position on d/t */
rectHeight = dlogRect.bottom - dlogRect.top;
rectWidth = dlogRect.right - dlogRect.left;
newH = (screenBits.bounds.right - rectWidth) * .50; /* centered horiz. */
if (newH < 10) /* not less than 10 */
newH = 10;
newV = ((screenBits.bounds.bottom - 30 /* vert position */
- rectHeight)* (.33)) + 30; /* one-third down */
if (newV < 30) /* not less than 30 */
newV = 30;
MoveWindow (myDlogPtr, newH, newV, TRUE); /* move to position */
ShowWindow (myDlogPtr); /* make visible */
(**prRecHdl).prJob.pIdleProc= (ProcPtr) myIdleProc; /* install idleproc */
PrOpenDoc(prRecHdl,prPortPtr,NIL); /* open the document */
destRect = (**prRecHdl).prInfo.rPage; /* printed page size */
destRect.top += 42; /* lower top for icon */
InsetRect (&destRect, 30,30); /* dest rect is smaller */
/* compute page scroll amount */
/* and recompute rect sizes. */
/* destRect a multiple of lineHeight */
outHeight = (**windTbl[Which].windTEH[0]).lineHeight;
outVert = destRect.bottom - destRect.top;
outScroll = (outVert / outHeight ) * outHeight;
destRect.bottom = destRect.top + outScroll;
viewRect = destRect; /* viewRect coincides */
myPrTEH = TENew(&destRect,&viewRect); /* get TE area for output */
/* copy font info to output */
(**myPrTEH).txFont = (**windTbl[Which].windTEH[0]).txFont;
(**myPrTEH).txFace = (**windTbl[Which].windTEH[0]).txFace;
(**myPrTEH).txSize = (**windTbl[Which].windTEH[0]).txSize;
/* point to text */
(**myPrTEH).hText = (**windTbl[Which].windTEH[0]).hText;
TECalText(myPrTEH); /* reset line begins */
outPageNo = 0; /* initialize page no */
outLines = (**myPrTEH).nLines; /* initial # of lines */
while ((outLines > 0) && (PrError() == 0))
{
PrOpenPage (prPortPtr, NIL); /* open the page */
/****************************************/
/* Draw the icon, or do any other */
/* graphic or text drawing you want. */
/****************************************/
SetRect (&IRect, 0,0, 32,32); /* draw the icon */
UseResFile (myResRefNum);
IHandle = GetResource ('ICN#', 128);
PlotIcon (&IRect, IHandle);
TEUpdate(&viewRect, myPrTEH); /* draw the text */
TEScroll(0, -outScroll, myPrTEH); /* scroll the text */
outLines -= outScroll/outHeight; /* new # of lines left */
PrClosePage (prPortPtr); /* close the page */
}
PrCloseDoc(prPortPtr); /* close the document */
SetPort(workGrafPtr); /* restore graf ptr */
if (((**prRecHdl).prJob.bJDocLoop==bSpoolLoop) /* if batch */
&& (PrError() == 0))
{
UseResFile (initResRefNum); /* for H/P printer */
PrPicFile (prRecHdl,prPortPtr,NIL,NIL,NIL); /* print the spool */
}
DisposDialog(myDlogPtr); /* get rid of dlog box */
break;
}
return PrintWindRetCode;
}